package com.ruoyi.web.wx.controller;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.ruoyi.web.wx.entity.TrashDetailedList;
import com.ruoyi.web.wx.service.ITrashDetailedListService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 回收垃圾清单类型 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-08-27
 */
@Controller
@RequestMapping("/system/trashDetailedList")
public class TrashDetailedListController extends BaseController
{
    private String prefix = "system/trashDetailedList";
	
	@Autowired
	private ITrashDetailedListService trashDetailedListService;
	
	@RequiresPermissions("system:trashDetailedList:view")
	@GetMapping()
	public String trashDetailedList()
	{
	    return prefix + "/trashDetailedList";
	}
	
	/**
	 * 查询回收垃圾清单类型列表
	 */
	@RequiresPermissions("system:trashDetailedList:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TrashDetailedList trashDetailedList)
	{
		startPage();
        List<TrashDetailedList> list = trashDetailedListService.selectTrashDetailedListList(trashDetailedList);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出回收垃圾清单类型列表
	 */
	@RequiresPermissions("system:trashDetailedList:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TrashDetailedList trashDetailedList)
    {
    	List<TrashDetailedList> list = trashDetailedListService.selectTrashDetailedListList(trashDetailedList);
        ExcelUtil<TrashDetailedList> util = new ExcelUtil<TrashDetailedList>(TrashDetailedList.class);
        return util.exportExcel(list, "trashDetailedList");
    }
	
	/**
	 * 新增回收垃圾清单类型
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存回收垃圾清单类型
	 */
	@RequiresPermissions("system:trashDetailedList:add")
	@Log(title = "回收垃圾清单类型", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TrashDetailedList trashDetailedList)
	{
		return toAjax(trashDetailedListService.insertTrashDetailedList(trashDetailedList));
	}

	/**
	 * 修改回收垃圾清单类型
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		TrashDetailedList trashDetailedList = trashDetailedListService.selectTrashDetailedListById(id);
		mmap.put("trashDetailedList", trashDetailedList);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存回收垃圾清单类型
	 */
	@RequiresPermissions("system:trashDetailedList:edit")
	@Log(title = "回收垃圾清单类型", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TrashDetailedList trashDetailedList)
	{		
		return toAjax(trashDetailedListService.updateTrashDetailedList(trashDetailedList));
	}
	
	/**
	 * 删除回收垃圾清单类型
	 */
	@RequiresPermissions("system:trashDetailedList:remove")
	@Log(title = "回收垃圾清单类型", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(trashDetailedListService.deleteTrashDetailedListByIds(ids));
	}
	/**
	 * 根据垃圾类型id查询回收垃圾清单类型列表
	 */
	@RequiresPermissions("system:trashDetailedList:list")
	@GetMapping("/listBytypeId")
	@ResponseBody
	public List<TrashDetailedList> listBytypeId(String typeId)
	{
		TrashDetailedList trashDetailed= new TrashDetailedList();
		trashDetailed.setTrashTypeId(typeId);
		List<TrashDetailedList> list = trashDetailedListService.selectTrashDetailedListList(trashDetailed);
		return list;
	}

}
